﻿using AutoMapper;
using Common.Communal;
using MediatR;
using Sell.Api.Write.Application.Command.CustomerCommand;
using Sell.Services.Customers;

namespace Sell.Api.Write.Application.CommandHandlers.CustomerCommadnHandlers
{
    public class CustomerDelCommandHandler : IRequestHandler<CustomerDelCommand, ApiResult<int>>
    {
        public ICustomerServices customer { get; }
        public CustomerDelCommandHandler(ICustomerServices _customer)
        {
            customer = _customer;
        }
        /// <summary>
        /// 客户管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<int>> Handle(CustomerDelCommand request, CancellationToken cancellationToken)
        {
            return await customer.DeleteCustomer(request.Id);
        }
    }
}